﻿<UserControl x:Class="BookManagementWpfApplication.Views.UserControl.BorrowBookView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vm="clr-namespace:BookManagementWpfApplication.ViewModels"
             xmlns:vu="clr-namespace:BookManagementWpfApplication.Views.UserControl"
             xmlns:converter="clr-namespace:BookManagementWpfApplication.Converters"
             mc:Ignorable="d" 
             FontFamily="Tahoma" FontSize="15"
             d:DesignHeight="2000" d:DesignWidth="970">
    
    <UserControl.Resources>
        <vm:BorrowBookViewModel x:Key="borrowBookViewModel" />
        <converter:BookStatusConvert x:Key="bookStatusConvert" />
        <converter:BookStatusConvertOfBorrow x:Key="bookStatusConvertOfBorrow" />
        <converter:DateToYearConvert x:Key="dateToYearConvert" />
    </UserControl.Resources>
    
    <ScrollViewer DataContext="{Binding Source={StaticResource borrowBookViewModel}}">
        <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="378" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition Height="60" />
            <RowDefinition Height="237" />
            <RowDefinition Height="275" />
            <RowDefinition Height="62*" />
                <RowDefinition Height="1306*" />
            </Grid.RowDefinitions>
        
        <StackPanel Name="stackPanel1" Orientation="Horizontal" Grid.ColumnSpan="2">
            <TextBlock Height="30" Name="textBlock1" Text="ยืม/คืน หนังสือ" FontSize="22" FontWeight="Bold" Margin="20,0,0,0" />
        </StackPanel>
        
        <Rectangle Height="1" Margin="11,50,5,9" Name="rectangle1" Stroke="Black" Width="auto" Grid.ColumnSpan="2" />
        
        <StackPanel Grid.ColumnSpan="2" Grid.Row="1" Name="stackPanel2" Orientation="Horizontal" HorizontalAlignment="Center">
            <TextBlock Height="23" Name="textBlock2" Text="รหัสหนังสือ : " FontWeight="Bold" Margin="10,5,5,0" />            
            <Label Content="Label" Height="28" Name="label1" Width="140" />
            <TextBlock Height="23" Name="textBlock3" Text="ชื่อหนังสือ : " FontWeight="Bold" Margin="25,5,5,0" />
            <Label Content="Label" Height="28" Name="label2" Width="250" />
            <TextBlock Height="23" Name="textBlock4" Text="สถานะ : " FontWeight="Bold" Margin="25,5,5,0" />            
            <Label Content="Label" Height="28" Name="label3" Width="130" Margin="0,0,5,0" />
            </StackPanel>
        
        <StackPanel Grid.Row="2" Grid.RowSpan="2" Name="stackPanel3" Margin="0">
            <StackPanel Name="stackPanel4" Orientation="Horizontal" Height="40">
                <TextBlock Height="23" Name="textBlock5" Text="- วันที่ยืม : " Margin="20,5,0,0" />
                <DatePicker Height="26" Name="datePicker1" Width="175" Margin="15,0,0,0" />
            </StackPanel>
            <StackPanel Name="stackPanel5" Orientation="Horizontal" Height="40">
                <TextBlock Height="23" Name="textBlock6" Text="- วันที่คืน : " Margin="20,5,0,0" />
                <DatePicker Height="26" Name="datePicker2" Width="175" Margin="15,0,0,0" />
            </StackPanel>
            <StackPanel Name="stackPanel6" Orientation="Horizontal" Height="40">
                <TextBlock Height="23" Name="textBlock7" Text="- ชื่อผู้ยืม : " Margin="20,3,0,0" />
                <ComboBox Height="23" Name="comboBox1" Width="250" Margin="15,0,0,0" />
            </StackPanel>
            <StackPanel Name="stackPanel7">
                <Button Content="ดูรายละเอียดเพิ่มเติม" Height="28" Name="button1" Width="190" Margin="25,0,0,5" />
            </StackPanel>
            <StackPanel Name="stackPanel8" Orientation="Horizontal">
                <TextBlock Height="23" Name="textBlock8" Text="- หมายเหตุ : " Margin="20,10,0,125" />
                <TextBox Height="145" Name="textBox4" Width="250" Margin="5,5,0,5" IsManipulationEnabled="True" />
            </StackPanel>
            <StackPanel Name="stackPanel9" Orientation="Horizontal" Height="42" HorizontalAlignment="Center">
                <Button Content="ยืม" Height="25" Name="button2" Width="60" Margin="5,0" />
                <Button Content="คืน" Height="25" Name="button3" Width="60" Margin="5,0" />
                <Button Content="ยกเลิก" Height="25" Name="button4" Width="70" Margin="5,0" />
            </StackPanel>
            <TextBlock Height="25" Name="textBlock13" Text="*ปุ่ม รายละเอียดผู้ยืม จะแสดงข้อมูลการยืมของผู้ยืมคนนั้น" Margin="10,15,0,0" />
        </StackPanel>
        
        <TextBlock Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="8,4,0,0" Name="textBlock9" Text="รายการหนังสือยืม / คงค้าง" VerticalAlignment="Top" FontSize="16" FontWeight="Bold" />
        
        <DataGrid AutoGenerateColumns="False" Grid.Column="1" Grid.Row="2" Name="dataGrid1" Margin="0,32,12,0" ItemsSource="{Binding Path=BorrowICV}">
            <DataGrid.Columns>
                <DataGridTextColumn Header="รหัสหนังสือ" Width="auto" Binding="{Binding Path=BookCode}" />
                <DataGridTextColumn Header="ชื่อหนังสือ" Width="auto" Binding="{Binding Path=BookName}" />
                <DataGridTextColumn Header="ประเภท" Width="auto" Binding="{Binding Path=BookType}" />
                <DataGridTextColumn Header="สถานะ" Width="auto" Binding="{Binding Path=BookStatus, Converter={StaticResource bookStatusConvertOfBorrow}}" />
                <DataGridTextColumn Header="วันที่ยืมหนังสือ" Width="auto" Binding="{Binding Path=BorrowDate}" />                
            </DataGrid.Columns>
        </DataGrid>
        
        <TabControl Grid.Column="1" Grid.Row="3" Name="tabControl1" Margin="0,14,12,12">
            <TabItem Header="หนังสือทั้งหมด" Name="tabItem1">
                <Grid>
                    <DataGrid AutoGenerateColumns="False" Name="dataGrid2" ItemsSource="{Binding Path=BookICV}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="รหัสหนังสือ" Width="auto" Binding="{Binding Path=BookCode}" />
                            <DataGridTextColumn Header="ชื่อหนังสือ" Width="auto" Binding="{Binding Path=BookName}" />
                            <DataGridTextColumn Header="ประเภท" Width="auto" Binding="{Binding Path=BookType}" />
                            <DataGridTextColumn Header="ปีที่จัดซื้อ" Width="auto" Binding="{Binding Path=DateOfPurchase, Converter={StaticResource dateToYearConvert}}" />
                            <DataGridTextColumn Header="สถานะ" Width="auto" Binding="{Binding Path=BookStatus, Converter={StaticResource bookStatusConvert}}" />
                            <DataGridTextColumn Header="หมายเหตุ" Width="200" Binding="{Binding Path=RemarkOfBook}" />
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>
            
            <TabItem Header="ประวัติการยืม" Name="tab2" >
                <Grid>
                    <DataGrid AutoGenerateColumns="False" Name="dataGrid3" ItemsSource="{Binding Path=BorrowICV}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="รหัสหนังสือ" Width="auto" Binding="{Binding Path=BookCode}" />
                            <DataGridTextColumn Header="ชื่อหนังสือ" Width="auto" Binding="{Binding Path=BookName}" />
                            <DataGridTextColumn Header="ประเภท" Width="auto" Binding="{Binding Path=BookType}" />
                            <DataGridTextColumn Header="ISBN" Width="auto" Binding="{Binding Path=ISBN}" />
                            <DataGridTextColumn Header="วันที่ยืม" Width="auto" Binding="{Binding Path=BorrowDate}" />
                            <DataGridTextColumn Header="วันที่คืน" Width="auto" Binding="{Binding Path=ReturnDate}" />
                            <DataGridTextColumn Header="หมายเหตุ" Width="200" Binding="{Binding Path=RemarkOfBorrow}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>
        </TabControl>             
        
        <Rectangle Grid.Row="2" Height="500" HorizontalAlignment="Left" Margin="370,0,0,0" Name="rectangle2" Stroke="Black" VerticalAlignment="Top" Width="1" Grid.RowSpan="2" />
        
        <TextBlock Grid.Column="1" Grid.Row="4" Height="25" HorizontalAlignment="Left" Name="textBlock11" Text="*หนังสือทั้งหมด จะแสดงเฉพาะรายชื่อหนังสือที่ยืมได้เท่านั้น" VerticalAlignment="Top" />
        <TextBlock Grid.Column="1" Grid.Row="4" Height="25" HorizontalAlignment="Left" Margin="0,31,0,0" Name="textBlock12" Text="*ประวัติการยืม จะแสดงรายชื่อหนังสือที่เคยยืมเท่านั้น" VerticalAlignment="Top" />
            
            <TabControl Grid.ColumnSpan="2" Grid.Row="5" Height="416" HorizontalAlignment="Left" Margin="11,32,0,0" Name="tabControl2" VerticalAlignment="Top" Width="930">
                <TabItem Header="tabItem2" Name="tabItem2">
                    <Grid>
                        
                    </Grid>
                </TabItem>
                
                <TabItem Header="tabItem3" Name="tabItem3">
                    <Grid>
                        
                    </Grid>
                </TabItem>
            </TabControl>
            
        </Grid>
   </ScrollViewer>
</UserControl>
